﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:system="clr-namespace:System;assembly=mscorlib">

  <Style x:Key="AcTb_ListBoxItemStyle" 
         TargetType="{x:Type ListBoxItem}">
      
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ListBoxItem}">
          <Border x:Name="Border"
                  BorderBrush="{TemplateBinding BorderBrush}"
                  BorderThickness="{TemplateBinding BorderThickness}"
                  Background="{TemplateBinding Background}"
                  Padding="{TemplateBinding Padding}"
                  SnapsToDevicePixels="true">
            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                              Margin="0 1 0 2" />
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsSelected" Value="true">
              <Setter Property="Background" TargetName="Border"
                      Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
              <Setter Property="Foreground" 
                      Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <SolidColorBrush x:Key="ListBorder" Color="#828790" />
  <Style x:Key="AcTb_ListBoxStyle" 
         TargetType="{x:Type ListBox}">
      
    <Setter Property="ItemContainerStyle" Value="{DynamicResource AcTb_ListBoxItemStyle}">
    </Setter>
    <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" />
    <Setter Property="BorderBrush" Value="{StaticResource ListBorder}" />
    <Setter Property="BorderThickness" Value="1" />
    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
    <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
    <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
    <Setter Property="ScrollViewer.CanContentScroll" Value="true" />
    <Setter Property="VerticalContentAlignment" Value="Center" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ListBox}">
          <Border x:Name="Border"
                  BorderBrush="{TemplateBinding BorderBrush}"
                  BorderThickness="{TemplateBinding BorderThickness}"
                  Background="{TemplateBinding Background}"
                  Padding="0"
                  SnapsToDevicePixels="true">
            <ScrollViewer Focusable="false"
                          Padding="{TemplateBinding Padding}"
                          Template="{DynamicResource AcTb_ScrollViewerControlTemplate}">
              <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
            </ScrollViewer>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Background" 
                      TargetName="Border"
                      Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
            </Trigger>
            <Trigger Property="IsGrouping" Value="true">
              <Setter Property="ScrollViewer.CanContentScroll" Value="false" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <LinearGradientBrush x:Key="ResizeGripperForeground"
                       EndPoint="1,0.75"
                       StartPoint="0,0.25">
    <GradientStop Color="#FFFFFF" Offset="0.3" />
    <GradientStop Color="#BBC5D7" Offset="0.75" />
    <GradientStop Color="#6D83A9" Offset="1" />
  </LinearGradientBrush>
  
    <Style x:Key="AcTb_ResizeGripStyle" 
         TargetType="{x:Type ResizeGrip}">
    <Setter Property="MinWidth" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" />
    <Setter Property="MinHeight" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}" />
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ResizeGrip}">
          <Grid SnapsToDevicePixels="true" Background="{TemplateBinding Background}">
            <Path Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Name="RG_TRIANGLE">
              <Path.Data>
                <PathGeometry Figures="M17,-1 L -1,17 17,17" />
              </Path.Data>
            </Path>
            <Path HorizontalAlignment="Right"
                  Margin="0,0,2,2"
                  VerticalAlignment="Bottom"
                  Data="M 9,0 L 11,0 L 11,11 L 0,11 L 0,9 L 3,9 L 3,6 L 6,6 L 6,3 L 9,3 z">
              <Path.Fill>
                <DrawingBrush TileMode="Tile"
                              Viewbox="0,0,3,3"
                              ViewboxUnits="Absolute"
                              Viewport="0,0,3,3"
                              ViewportUnits="Absolute">
                  <DrawingBrush.Drawing>
                    <DrawingGroup>
                      <GeometryDrawing Brush="{StaticResource ResizeGripperForeground}"
                                       Geometry="M 0,0 L 2,0 L 2,2 L 0,2 z " />
                    </DrawingGroup>
                  </DrawingBrush.Drawing>
                </DrawingBrush>
              </Path.Fill>
            </Path>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <ControlTemplate x:Key="AcTb_ScrollViewerControlTemplate"
                   TargetType="{x:Type ScrollViewer}">
    <Grid>
      <Grid x:Name="Grid"
            Background="{TemplateBinding Background}">
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="*" />
          <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
          <RowDefinition Height="*" />
          <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Rectangle x:Name="Corner"
                   Grid.Column="1"
                   Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
                   Grid.Row="1" />
        <ScrollContentPresenter x:Name="PART_ScrollContentPresenter"
                                CanContentScroll="{TemplateBinding CanContentScroll}"
                                CanHorizontallyScroll="False"
                                CanVerticallyScroll="False"
                                ContentTemplate="{TemplateBinding ContentTemplate}"
                                Content="{TemplateBinding Content}"
                                Grid.Column="0"
                                Margin="{TemplateBinding Padding}"
                                Grid.Row="0" />
        <ScrollBar x:Name="PART_VerticalScrollBar"
                   AutomationProperties.AutomationId="VerticalScrollBar"
                   Cursor="Arrow"
                   Grid.Column="1"
                   Maximum="{TemplateBinding ScrollableHeight}"
                   Minimum="0"
                   Grid.Row="0"
                   Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                   Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                   ViewportSize="{TemplateBinding ViewportHeight}"
                   Margin="0 17 0 0">
        </ScrollBar>
        <ScrollBar x:Name="PART_HorizontalScrollBar"
                   AutomationProperties.AutomationId="HorizontalScrollBar"
                   Cursor="Arrow"
                   Grid.Column="0"
                   Maximum="{TemplateBinding ScrollableWidth}"
                   Minimum="0"
                   Orientation="Horizontal"
                   Grid.Row="1"
                   Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                   Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                   ViewportSize="{TemplateBinding ViewportWidth}" />
      </Grid>

      <ResizeGrip HorizontalAlignment="Right"
                  VerticalAlignment="Top"
                  Style="{DynamicResource AcTb_ResizeGripStyle}"
                  Cursor="SizeNESW"
                  Name="ResizeGrip">
        <ResizeGrip.LayoutTransform>
          <ScaleTransform ScaleX="1" ScaleY="-1" />
        </ResizeGrip.LayoutTransform>
      </ResizeGrip>
    </Grid>
    <ControlTemplate.Triggers>
      <Trigger Property="ComputedVerticalScrollBarVisibility" Value="Visible">
        <Setter TargetName="ResizeGrip"
                Property="Background"
                Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>

</ResourceDictionary>